package com.feng.springboothelloworld.config;

import org.springframework.cglib.core.Local;
import org.springframework.util.StreamUtils;
import org.springframework.web.servlet.LocaleResolver;
import org.thymeleaf.util.StringUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;

public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest httpServletRequest) {
        String l=httpServletRequest.getParameter("l");
        System.out.println("-------------111");
        Locale local=Locale.getDefault();
        if(!StringUtils.isEmpty(l))
        {
            String[]split=l.split("_");
            local=new Locale(split[0],split[1]);
        }
        return local;
    }

    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {

    }
}
